package com.hgz;

import java.util.List;
import javax.jdo.PersistenceManager;

public class ItemDao {

	void addItem(Item item){
		PersistenceManager pm = PMF.get().getPersistenceManager();

		try {
			pm.makePersistent(item);
			pm.deletePersistent(item);
		} finally {
			pm.close();

		}
	}

	List<Item> getAllItem(){
		PersistenceManager pm = PMF.get().getPersistenceManager();
		String query = "select from " + Item.class.getName()  ;
		List<Item> items = (List<Item>) pm.newQuery(query).execute();
		return items;
	}
	
	public static void main(String args[]){
		Item item = new Item();
		item.setDw("斤");
		item.setMaxPrice("2.0");
		item.setMinPrice("1.0");
		item.setName("土豆");
		item.setPrice("1.5");
		new ItemDao().addItem(item);
	}
}